package com.opengl.camera;

import com.opengl.camera.R;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.ViewGroup.LayoutParams;

public class MainActivity extends Activity {
	private CameraGLSurfaceView m_glView;
	private CameraPreview m_camPreview;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		//setContentView(R.layout.activity_main); goodbye world!
		m_glView = new CameraGLSurfaceView(this);
		m_camPreview = new CameraPreview(this, m_glView);
		
		// make sure to always show the cool 3D stuff on top of the preview
		m_glView.setZOrderMediaOverlay(true);
		
		// setup the surfaces and add them to the view so we can see them
		setContentView(m_camPreview, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		addContentView(m_glView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	}

	@Override
	protected void onPause() {
		super.onPause();
		// The following call pauses the rendering thread.
		// If your OpenGL application is memory intensive,
		// you should consider de-allocating objects that
		// consume significant memory here.
		m_glView.onPause();
		m_camPreview.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();
		// The following call resumes a paused rendering thread.
		// If you de-allocated graphic objects for onPause()
		// this is a good place to re-allocate them.
		m_glView.onResume();
		m_camPreview.onResume();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
